#include <iostream>
#include "bitmap.h"

using std::cout;
using std::endl;

class BloomFilter
{
public:
    void add(int val)
    {
        for(int i{123}; i < 126; i ++){
            int rand1 = i * 9244 / 142 * val % 1000;
            bitmap_.add(rand1);
        }
    }

    bool contain(int val) const
    {
        int flag = 0;
        for(int i{123}; i < 126; i ++){
            int rand1 = i * 9244 / 142 * val % 1000;
            if(bitmap_.contain(rand1)) {
                flag ++;
            }
        }

        return flag == 3;
    }

private:
    Bitmap bitmap_;
};

void test1()
{
    BloomFilter bloom;
    bloom.add(30);
    bloom.add(90);
    bloom.add(1);

    cout << std::boolalpha;
    cout << bloom.contain(1) << endl;
    cout << bloom.contain(30) << endl;
    cout << bloom.contain(90) << endl;
    cout << bloom.contain(91) << endl;
}

int main(int args, char *argv[])
{
    test1();
    return 0;
}